//
//  ContentCellCollectionViewCell.swift
//  GhostWorld
//
//  Created by Kam on 2018/9/26.
//  Copyright © 2018 LKGood. All rights reserved.
//

import UIKit

class ContentCell: UICollectionViewCell {
  
  // MARK: - IBOutlets
  
  @IBOutlet private weak var coverImageView: CoverImageView!
  @IBOutlet private weak var nameLabel: UILabel!
  
  @IBOutlet private weak var groupView: UIView!
  @IBOutlet private weak var groupCoverImageView: CoverImageView!
  
  // MARK: - Private vars
  
  
  
  // MARK: - Private methods
  
  
  
  // MARK: - Public vars
  
  
  
  // MARK: - Lifecycle
  
  override func awakeFromNib() {
    super.awakeFromNib()
    backgroundColor = .clear
  }
  
  override func prepareForReuse() {
    super.prepareForReuse()
    
    coverImageView.image = nil
    groupCoverImageView.image = nil
    coverImageView.isHidden = true
    groupView.isHidden = true
  }
  
  // MARK: - IBActions
  
  
  
  // MARK: - Public methods
  
  func prepare(item: VIPAllResultItem) {
    nameLabel.text = item.name
    
    if item.type == .album {
      coverImageView.isHidden = false
      groupView.isHidden = true
      coverImageView.af_setImage(withURL: item.coverImageURL)
    } else {
      coverImageView.isHidden = true
      groupView.isHidden = false
      groupCoverImageView.af_setImage(withURL: item.coverImageURL)
    }
  }
}
